import tkinter as tk

root = tk.Tk()

text = tk.Text(root, width=20, height=5)
text.pack()

text.insert("insert", "I love Python.com!dryhsdrhyerhyehrehgergdrfgerhwehwrhrwhrhhrwehwreherheg ")


# 将任何格式的索引号统一为元组 (行,列) 的格式输出
def getIndex(pos):
    return tuple(map(int, str.split(text.index(pos), ".")))


start = 1.0
while True:
    pos = text.search("g", start, stopindex="end")
    print(pos)
    if not pos:
        break
    b = getIndex(pos)
    print(b)
    start = pos + "+1c"  # 将 start 指向下一个字符
r = int(b[0])
t = int(b[1])
while True:
    if t > 25:
        t -= 25
        r += 1
    else:
        r += 1
        break
print(str(r) + '.' + str(t))
root.mainloop()
